package com.pp.activites;

import com.pp.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Toast;


/** Menu principal PP
 * 
 * @author fcamps
 *
 */
public class MainActivity extends Activity implements OnClickListener
{
	private Intent intentControl;

	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
		
		// chargement IHM menu principal
		setContentView(R.layout.main_menu);

		//Attachement au controler
		findViewById(R.id.imageButtonCrontrol).setOnClickListener(this);
		findViewById(R.id.imageButtonInventory).setOnClickListener(this);
		findViewById(R.id.imageButtonMeasureTube).setOnClickListener(this);
		findViewById(R.id.imageButtonStock).setOnClickListener(this);
		findViewById(R.id.imageButtonHSE).setOnClickListener(this);
		findViewById(R.id.imageButtonSettings).setOnClickListener(this);

		// exemple d'ouverture d'un ecran dans la meme activity
		// attention il faut recuperer tous les boutons ...
		/* LayoutInflater layoutInflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view = layoutInflater.inflate(R.layout.main_menu, null);
		setContentView(view); */
	}
	
	 @Override
	  public boolean onCreateOptionsMenu(Menu menu) 
	 {
	    MenuInflater inflater = getMenuInflater();
	    inflater.inflate(R.menu.main_menu, menu);
	    return true;
	  }
	

	@Override
	public void onClick(View v)
	{
		switch (v.getId()) 
		{
		case R.id.imageButtonCrontrol:
			intentControl = new Intent(this, ControlTube.class);
			startActivity(intentControl);
			finish();
			break;

		case R.id.imageButtonMeasureTube:
			intentControl = new Intent(this, Measure.class);
			startActivity(intentControl);
			finish();
			break;

		case R.id.imageButtonInventory:
			intentControl = new Intent(this, Inventory.class);
			startActivity(intentControl);
			finish();
			break;

		case R.id.imageButtonStock:
			Toast.makeText(getApplicationContext(), "imageButtonStock", Toast.LENGTH_SHORT).show();
			break;

		case R.id.imageButtonHSE:
			Toast.makeText(getApplicationContext(), "imageButtonHSE", Toast.LENGTH_SHORT).show();
			break;

		case R.id.imageButtonSettings:
			Toast.makeText(getApplicationContext(), "imageButtonSettings", Toast.LENGTH_SHORT).show();
			break;
		}
	}
	
}
